package cn.livingCloud.dto;

import cn.livingCloud.entity.core.Case;
import cn.livingCloud.entity.core.CaseImage;
import cn.livingCloud.entity.core.CaseStatus;
import cn.livingCloud.entity.core.Employee;
import cn.livingCloud.utils.DateUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DingJie on 2016/6/2.
 */
public class CaseDto {

    protected String createDateTime;
    protected Boolean archive;
    private String uuid;
    private String addressDescription;
    private String phone;
    private Float locationX;
    private Float locationY;
    private CaseStatus status;
    private String creatorUuid;
    private MemberDto creator;
    private String ownerId;
    private List<EmployeeDto> ownerList = new ArrayList<>();
    private String caseCategoryUuid;
    private CaseCategoryDto caseCategoryDto;
    private List<CaseImageDto> caseImageDtoList = new ArrayList<>();
    private CaseStatus disableStatus;

    public CaseDto(Case item) {
        this.creatorUuid = item.getCreatorUuid();
        this.addressDescription = item.getAddressDescription();
        this.locationX = item.getLocationX();
        this.locationY = item.getLocationY();
        this.status = item.getStatus();
        this.ownerId = item.getOwnerId();
        this.phone = item.getPhone();
        this.uuid = item.getUuid();
        this.createDateTime = DateUtils.toDateText(item.getCreateDateTime()
                , DateUtils.DEFAULT_DATE_TIME_FORMAT);
        this.archive = item.getArchive();
        this.disableStatus = item.getDisableStatus();
        if (item.getMember() != null) {
            this.creator = new MemberDto(item.getMember());
        }
        List<Employee> ownerList = item.getOwnerList();
        if (!ownerList.isEmpty()) {
            for (Employee employee : ownerList) {
                this.ownerList.add(new EmployeeDto(employee));
            }
        }
        this.caseCategoryUuid = item.getCaseCategoryUuid();
        if (item.getCaseCategory() != null) {
            this.caseCategoryDto = new CaseCategoryDto(item.getCaseCategory());
        }
        List<CaseImage> allCaseImages = item.getAllCaseImages();
        if (allCaseImages != null) {
            for (CaseImage caseImage : allCaseImages) {
                this.caseImageDtoList.add(new CaseImageDto(caseImage));
            }
        }
    }

    public List<EmployeeDto> getOwnerList() {
        return ownerList;
    }

    public CaseDto setOwnerList(List<EmployeeDto> ownerList) {
        this.ownerList = ownerList;
        return this;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getCreatorUuid() {
        return creatorUuid;
    }

    public void setCreatorUuid(String creatorUuid) {
        this.creatorUuid = creatorUuid;
    }

    public String getAddressDescription() {
        return addressDescription;
    }

    public void setAddressDescription(String addressDescription) {
        this.addressDescription = addressDescription;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Float getLocationX() {
        return locationX;
    }

    public void setLocationX(Float locationX) {
        this.locationX = locationX;
    }

    public Float getLocationY() {
        return locationY;
    }

    public void setLocationY(Float locationY) {
        this.locationY = locationY;
    }

    public CaseStatus getStatus() {
        return status;
    }

    public void setStatus(CaseStatus status) {
        this.status = status;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }

    public String getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(String createDateTime) {
        this.createDateTime = createDateTime;
    }

    public Boolean getArchive() {
        return archive;
    }

    public void setArchive(Boolean archive) {
        this.archive = archive;
    }

    public MemberDto getCreator() {
        return creator;
    }

    public void setCreator(MemberDto creator) {
        this.creator = creator;
    }

    public String getCaseCategoryUuid() {
        return caseCategoryUuid;
    }

    public void setCaseCategoryUuid(String caseCategoryUuid) {
        this.caseCategoryUuid = caseCategoryUuid;
    }

    public CaseCategoryDto getCaseCategoryDto() {
        return caseCategoryDto;
    }

    public void setCaseCategoryDto(CaseCategoryDto caseCategoryDto) {
        this.caseCategoryDto = caseCategoryDto;
    }

    public List<CaseImageDto> getCaseImageDtoList() {
        return caseImageDtoList;
    }

    public void setCaseImageDtoList(List<CaseImageDto> caseImageDtoList) {
        this.caseImageDtoList = caseImageDtoList;
    }

    public CaseStatus getDisableStatus() {
        return disableStatus;
    }

    public CaseDto setDisableStatus(CaseStatus disableStatus) {
        this.disableStatus = disableStatus;
        return this;
    }
}
